package car.aistar.dao;

import car.aistar.dto.XXRyuyue;
import car.aistar.dto.XxrCarDto;
import car.aistar.dto.XxrRecordDto;
import car.aistar.dto.Xxrkanjia;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * @ClassName xxryuye
 * @Description TODO
 * @Author 肖
 * @Date 2020/10/4 19:55
 * Version 1.0
 **/
public interface XXRxiaohsou {
////    /**
////     *@Author 肖相荣
////     *@Description //TODO 销售页面预约表根据预约表中carID进行删除预约记录(出现问题，舍弃)
////     *@Date 17:51 2020/10/5
////     *@Param [id]
////     *@return void
////     **/
//    @Delete("DELETE from reserve where res_car_id = ${value}")
//    void delByCarId(Long id);
    /**
    *@Author 肖相荣
    *@Description //TODO 预约表的查询
    *@Date 18:52 2020/10/5
    *@Param [id, search]
    *@return java.util.List<car.aistar.dto.XXRyuyue>
    **/
    @Select("select  r.id as id , r.res_time as resTime,u.uname uname,u.uphone as uphone,r.res_car_id as resCarId,c.car_carNumber as carCarnumber from user_detail u,car_detail c,reserve r where r.res_car_id=c.id and r.u_id=u.id and r.s_id=${id} and r.res_status=0 and  concat(r.res_time,u.uname,u.uphone,r.res_car_id,c.car_carNumber) like '%${search}%'")
    List<XXRyuyue> findAllYuyue(@Param("id") Long id, @Param("search") String search);

    /**
     *@Author 肖相荣
     *@Description //TODO 预约成功表的查询
     *@Date 18:52 2020/10/5
     *@Param [id, search]
     *@return java.util.List<car.aistar.dto.XXRyuyue>
     **/
    @Select("select  r.id as id , r.res_time as resTime,u.uname uname,u.uphone as uphone,r.res_car_id as resCarId,c.car_carNumber as carCarnumber from user_detail u,car_detail c,reserve r where r.res_car_id=c.id and r.u_id=u.id and r.s_id=${id} and r.res_status=1 and  concat(r.res_time,u.uname,u.uphone,r.res_car_id,c.car_carNumber) like '%${search}%'")
    List<XXRyuyue> findAllYok(@Param("id") Long id, @Param("search") String search);
    /**
    *@Author 肖相荣
    *@Description //TODO 砍价表的查询
    *@Date 18:52 2020/10/5
    *@Param [id, search]
    *@return java.util.List<car.aistar.dto.Xxrkanjia>
    **/
    @Select("select r.id as id, u.uname as uname,u.uphone as uphone,r.ca_baseprice as caBaseprice,r.ca_price as caPrice,r.ca_sellprice as caSellprice, r.c_id as cId from user_detail u, car_cart r,car_detail c where r.c_id=c.id and r.u_id=u.id and c.sal_id=${id}  and concat(u.uname ,u.uphone ,r.ca_baseprice,r.ca_price ,r.ca_sellprice ) like '%${search}%' ")
    List<Xxrkanjia> findAllKanjia(@Param("id") Long id, @Param("search") String search);

    /**
    *@Author 肖相荣
    *@Description //TODO 销售人员页面的负责车辆表的查询
    *@Date 18:53 2020/10/5
    *@Param [id]
    *@return void
    **/
    @Select("select c.id as carId, o.oname as oname , o.ophone as ophone , c.c_createDate as createDate , c.c_price as caBaseprice  , c.c_oprice as caSellprice , c.c_status as cStatus from car_detail c, carowner o where  c.id = o.c_id  and  c.sal_id=${id} and concat(c.id , o.oname , o.ophone , c.c_createDate , c.c_price  , c.c_oprice , c.c_status) like '%${search}%'")
    List<XxrCarDto> findAllCar(@Param("id") Long id,@Param("search") String search);
    /**
    *@Author 肖相荣
    *@Description //TODO 销售人员页面交易记录表查询
    *@Date 22:02 2020/10/6
    *@Param [id]
    *@return void
    **/
    @Select("select r.id as id,r.c_id as carId,u.uname as uname,u.uphone as uphone,o.oname as oname,o.ophone as ophone,r.c_oprice as cOprice,r.re_price as rePrice,r.re_time as reTime from  car_record as r,user_detail as u,carowner as o where r.o_id = o.id and r.u_id=u.id and r.s_id =${id} and concat(r.id ,r.c_id ,u.uname , u.uphone , o.oname , o.ophone ,r.c_oprice ,r.re_price , r.re_time) like '%${search}%'")
    List<XxrRecordDto> findAllRecord(@Param("id") Long id, @Param("search") String search);

    @Delete("delete from car_cart where c_id = ${value}")
    void delKanjia(Long id);
}
